<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {$LOAD_STYLE.top|raw}
</head>
<style>
.tr1 td{
	background-color: #f8fbff;
}
.tr2 td{
	background-color: #fffffb;
}
</style>
<script src="__JS__/clipboard.min.js"></script>
	<body class="pear-container">
		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form layui-form-pane" action="">
					<div class="layui-form-item">
						
                        <input type="hidden" name="cusid" value="{:$cusid}" placeholder="" class="layui-input">
						
						<div class="layui-form-item layui-inline">
						    <label class="layui-form-label">编号</label>
						    <div class="layui-input-inline">
						        <input type="text" name="number" placeholder="请输入完整编号" class="layui-input">
						    </div>
						</div>
						
						<div class="layui-form-item layui-inline">
						    <label class="layui-form-label">色号</label>
						    <div class="layui-input-inline">
						        <input type="text" name="color" placeholder="" class="layui-input">
						    </div>
						</div>
						
                        <div class="layui-form-item layui-inline">
                       <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="query">
                           <i class="layui-icon layui-icon-search"></i>
                           查询
                       </button>
                       <button type="reset" class="pear-btn pear-btn-md">
                           <i class="layui-icon layui-icon-refresh"></i>
                           重置
                       </button>
                       </div>
                    </div>
				</form>
			</div>
		</div>
		<div class="layui-card">
			<div class="layui-card-body">
				<table id="dataTable" lay-filter="dataTable"></table>
			</div>
		</div>

		<script type="text/html" id="toolbar">

		</script>

        <script type="text/html" id="customer">
		<div copy="{{d.deal.customer.name}},{{d.deal.customer.phone}},{{d.deal.customer.address2}}">
			<a href="javascript:;" title="点击复制客户地址信息">{{ d.deal.customer.name }}</a>
		</div>
		</script>

		<script type="text/html" id="options">
		<div class="layui-options">
			<button class="pear-btn pear-btn-primary pear-btn-sm" {if isMobile()} lay-event="link" {else/} lay-event="pop" {/if} url="{:U('deal.main/printing')}/id/{{d.did}}/number/{{d.deal.number}}" poptitle="【{{ d.deal.customer.name }}】订单明细" popsize="1"><i class="layui-icon layui-icon-print"></i></button>
			<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="jump" url="{:U('deal.main/edit')}/id/{{d.did}}"><i class="layui-icon layui-icon-edit"></i></button>
		</div>

		</script>
        <script>
        layui.use(['jquery','common','mycomm','table'], function() {
            let $ = layui.jquery;
			let common = layui.common;
			let mycomm = layui.mycomm;
			let table = layui.table;
            let MODULE_PATH = "{$MODULE_PATH}";
			let table_name = "dataTable";
            
            let cols = [
                [ {
                       field: "create_time2",
                       title: "下单时间",
					   width: 105,
					   templet: "<div>{{ d.deal.create_time2 }}</div>",
                       unresize: "true",
                       align: "center",
				   {if($cusid==0)}
                   }, {
                       field: "customer",
                       title: "客户昵称",
					   width: 100,
					   templet: "#customer",
                       unresize: "true",
                       align: "center",
				   {/if}
                   }, {
                       field: "number",
                       title: "编号",
					   width: 80,
                       unresize: "true",
                       align: "center",
                   }, {
                       field: "name",
                       title: "品名",
					   width: 180,
                       unresize: "true",
                       align: "left",
                   }, {
                       field: "color",
                       title: "色号",
					   width: 60,
                       unresize: "true",
                       align: "center",
                   }, {
                       field: "colorname",
                       title: "颜色",
					   width: 80,
                       unresize: "true",
                       align: "center",
                   }, {
                       field: "colorval",
                       title: "",
					   width: 40,
					   templet: "<div>&nbsp;</div>",
                       unresize: "true",
                       align: "center",
					},
					{for start="0" end="8"}
					{
					    field: "weight{$i}",
					    title: "{$i+1}",
						width: 60,
						templet: "<div>{{ d.weight[{$i}] }}</div>",
					    unresize: "true",
					    align: "center",
                   },
				   {/for}
				   {
                       field: "count",
                       title: "数量",
					   width: 90,
					   templet: "<div>{{ d.count }} {{ d.unit }}</div>",
                       unresize: "true",
                       align: "center",
                   }, {
                       field: "unitprice",
                       title: "单价",
					   width: 60,
					   templet: "<div>{{ d.unitprice }}</div>",
                       unresize: "true",
                       align: "center",
					// }, {
					// 	field: "total",
					// 	title: "总金额",
					// 	width: 120,
					// 	templet: "<div>{{d.total}} 元</div>",
					// 	unresize: "true",
					// 	align: "center",
                   }, {
                       field: "bacth",
                       title: "缸号",
					   width: 120,
                       unresize: "true",
                       align: "center",
                   }, {
                       field: "courier",
                       title: "快递名称",
					   width: 100,
					   templet: "<div>{{ d.deal.courier }}</div>",
                       unresize: "true",
                       align: "center",
                   }, {
                        title: '操作',
                        toolbar: '#options',
						width: 120,
                        unresize: true,
                        align: 'left',
                    }
                ]
            ]
			
			table.render({
				elem: '#dataTable',
				url: MODULE_PATH + 'history',
				where:{cusid:{:$cusid}},
				page: true,
				cols: cols,
				cellMinWidth: 100,
				even: true,
				limit: 30,
				toolbar: '#toolbar',
				defaultToolbar: [{
					title: '刷新',
					layEvent: 'refresh',
					icon: 'layui-icon-refresh',
				}, 'filter', 'print', 'exports'],
				done:function(res,curr,count){
					var now=0;
					var tr="tr1";
					{if ($cusid==0)}
					var $wz=6;
					{else/}
					var $wz=5;
					{/if}
					if(res.data!=undefined){
						for (let i=0; i < res.data.length; i++) {
							if(now==0){
								now=res.data[i].did;
							}else if(now!=res.data[i].did){
								tr=tr=="tr1"?"tr2":"tr1";
								now=res.data[i].did;
							}
							$('[data-index='+i+']').addClass(tr);
							
							if(res.data[i].gray==0){
								$("[data-index="+i+"] [data-key='1-0-"+$wz+"']").css("background-color","#"+res.data[i].colorval);
							}else if(res.data[i].gray==1){
								
							}
						};
					}
				}
			});
			
			mycomm.tableTool('{$controller_title}',MODULE_PATH,table_name);
			mycomm.tableToolBar('{$controller_title}',MODULE_PATH,table_name);
			mycomm.search_table(table_name);
 
 
        })
    </script>
	{$LOAD_STYLE.bottom|raw}
	</body>
</html>
